package com.fypg.module.medical.dal.mysql.internethospital;

import com.fypg.framework.mybatis.core.mapper.BaseMapperX;
import com.fypg.module.medical.controller.app.internethospital.vo.AppInternetHospitalVO;
import com.fypg.module.medical.dal.dataobject.hospitalarea.HospitalAreaDO;
import com.fypg.module.medical.dal.dataobject.internethospital.InternetHospitalDO;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 互联网医院 Mapper
 *
 * @author PJY
 */
@Mapper
public interface InternetHospitalMapper extends BaseMapperX<InternetHospitalDO> {

    /**
     * 查询互联网医院
     *
     * @return 互联网医院 DO 列表
     */
    default List<AppInternetHospitalVO> selectInternetHospitalVOList() {
        MPJLambdaWrapper<InternetHospitalDO> wrapper = new MPJLambdaWrapper<InternetHospitalDO>()
            .selectAll(InternetHospitalDO.class)
            .selectAs(HospitalAreaDO::getHospitalAreaName, AppInternetHospitalVO::getHospitalAreaName)
            .innerJoin(HospitalAreaDO.class, HospitalAreaDO::getId, InternetHospitalDO::getHospitalAreaId)
            .eq(InternetHospitalDO::getDeleted, 0)
            .eq(InternetHospitalDO::getEnabledMark, 1)
            .orderByAsc(InternetHospitalDO::getSortCode);

        return this.selectJoinList(AppInternetHospitalVO.class, wrapper);
    }

}
